﻿using Coldairarrow.Business.DataView;
using Coldairarrow.Entity.DataView;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.DataView
{
    [Route("/DataView/[controller]/[action]")]
    public class blade_visual_mapController : BaseApiController
    {
        #region DI

        public blade_visual_mapController(Iblade_visual_mapBusiness blade_visual_mapBus)
        {
            _blade_visual_mapBus = blade_visual_mapBus;
        }

        Iblade_visual_mapBusiness _blade_visual_mapBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<blade_visual_map>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _blade_visual_mapBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<blade_visual_map> GetTheData(IdInputDTO input)
        {
            return await _blade_visual_mapBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(blade_visual_map data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _blade_visual_mapBus.AddDataAsync(data);
            }
            else
            {
                await _blade_visual_mapBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _blade_visual_mapBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}